package com.chixing.controller;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("ai")
@CrossOrigin(origins = "*") // 支持跨域请求
public class QianwenChatController {
    private final ChatClient chatClient;

    public QianwenChatController(ChatClient.Builder chatClientBuilder){
        this.chatClient = chatClientBuilder.build();
    }

    // 模拟 通义千问的文本对话模型
    @GetMapping("chat")
    public String chat(@RequestParam("message") String message){
        return chatClient.prompt().user(message).call().content();
    }

}
